package com.hnzq.cloud.freshuserassembly.util;

import lombok.Data;

import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @author Administrator
 */
@Data
public class DateFormatUtil {

    public static Long parseDateString(String time, String pattern) {

        SimpleDateFormat sdf = new SimpleDateFormat(pattern);

        try {
            return sdf.parse(time).getTime();
        } catch (ParseException exception) {
            exception.printStackTrace();
            return null;
        }
    }

    public static String parseDateLong(long time, String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(new Date(time));
    }

}